package com.service.scheduler.job;

import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.service.alarm.StatisticsAlarm;
import com.service.bean.device.Vehicle;
import com.service.cache.CacheManager;
import com.service.other.Logger;

/**
 * 排班开始定时器</br>
 * 处理车辆是否在规定时间内出勤判断
 * @author lj
 *
 */
public class DutyStartJob implements Job {

	public DutyStartJob() {
		
	}
	
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		Logger.println("车辆上班定时器启动");
		// 获取JobDetail，并从其中获取放在缓存中的数据
		JobDetail job = context.getJobDetail();
		String gpsNo = job.getJobDataMap().getString("gpsno");
		Vehicle vehicle = CacheManager.instance().getVehicle(gpsNo);
		if (null == vehicle) {
			Logger.debug(gpsNo, "根据GpsNo无法从缓存中获取车辆, 上班考勤检查取消");
			return;
		}
		StatisticsAlarm alarm = new StatisticsAlarm();
		alarm.workStartDutyStatistics(vehicle);
	}

}
